import type { TableColumn } from '@/framework/components/core/super-table';
import dayjs from 'dayjs';

export type TableListItem = { optCode; createTime; count; id };
export type TableColumnItem = TableColumn<TableListItem>;

// 记录类型
export const typeObj = {
  // 1001: '暂存样本入库', // 废弃
  // 1002: '保藏样本入库', // 废弃
  1003: '样本出库',
  1004: '提醒处理',
  1005: '样本入库',
  1006: '样本移库',
  1008: '样本核销',
};

export const baseColumns: TableColumnItem[] = [
  {
    type: 'seq',
    title: '序号',
    width: 60,
  },
  {
    title: '记录类型',
    field: 'optCode',
    formatter: ({ cellValue }) => {
      return typeObj[cellValue];
    },
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: Object.values(typeObj).map((item, index) => ({
          label: item,
          value: Object.keys(typeObj)[index],
        })),
      },
    },
  },
  {
    title: '记录时间',
    field: 'createTime',
    searchField: 'createTimeBtw',
    formatter: ({ cellValue }) => {
      return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : '-';
    },
    formItemProps: {
      component: 'RangePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD',
      },
    },
  },
  {
    title: '操作数量',
    field: 'count',
    hideInSearch: true,
  },
];
